package com.kidala.tool;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


public class CopyStreams {

    private static final int IO_BUFFER_SIZE = 1024;

    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream("C:/file.pdf");
        FileOutputStream fileOutputStream = new FileOutputStream("C:/file_copy.pdf");
        copy(fileInputStream, fileOutputStream);
    }

    private static void copy(InputStream in, OutputStream out) throws IOException {
        byte[] b = new byte[IO_BUFFER_SIZE];
        int read;
        while ((read = in.read(b)) != -1) {
            out.write(b, 0, read);
        }
    }

}
